import type { CommonResponseData } from '@/api/user/type'
import request from '@/utils/request'
import type { PageData, TradeMarkData } from './types'

const enum Api {
  LIST = '/tradeMark/list',
  ADD = '/tradeMark/add',
  EDIT = '/tradeMark/edit',
  DELETE = '/tradeMark/delete',
}

export const reqTradeMarkList = (pageNo: number, pageSize: number) =>
  request.get<any, CommonResponseData<PageData<TradeMarkData>>>(
    Api.LIST + '?pageNo=' + pageNo + '&pageSize=' + pageSize
  )

export const saveList = (data: TradeMarkData) => {
  let url = Api.ADD
  if (data.id) {
    url = Api.EDIT
  }
  return request.post<any, CommonResponseData<TradeMarkData>>(url, data)
}

export const deleteTradeMark = (id: number) => {
  return request.delete<any, CommonResponseData<boolean>>(
    Api.DELETE + '?id=' + id
  )
}
